<template>
  <ul class="catagtory">
    <li
      :class="{ select: currentId === item.id }"
      v-for="item in typeList"
      :key="item.id"
      @click="liClick(item.id)"
    >
      {{ item.name }}
    </li>
  </ul>
</template>

<script>
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState('type', ['typeList', 'currentId'])
  },
  created () {
    this.$store.dispatch('type/getTypeList')
  },
  methods: {
    liClick (id) {
      this.$store.commit('type/setCurrentId', id)
      this.$store.dispatch('list/getInfoList', id)
    }
  }
}
</script>

<style lang="less"></style>
